
 package com.ami.iusb;
 
 import com.ami.kvm.jviewer.Debug;
 import com.ami.kvm.jviewer.gui.JViewerApp;
 import com.ami.vmedia.VMApp;
 import com.ami.vmedia.gui.DeviceControlPanel;
 import com.ami.vmedia.gui.VMPane;
 
 public class vCDMonitorThread extends Thread
 {
   private CDROMRedir cdromRedir = null;
   private String[] cdromList = null;
   private String cdromSource = null;
   private boolean cdromThreadStatus = false;
   private boolean isMediaMatched = false;
   private int cddevice_no = 0;
   
   public vCDMonitorThread(int paramInt) {
     this.cddevice_no = paramInt;
   }
   
 
 
 
 
   public void startCDROMMonitor()
   {
     this.cdromThreadStatus = true;
     start();
   }
   
 
 
 
 
   public void stopCDROMMonitor()
   {
     this.cdromThreadStatus = false;
   }
   
 
 
 
   public void run()
   {
     this.cdromRedir = new CDROMRedir(true);
     this.cdromSource = VMApp.getInstance().getIUSBRedirSession().getCDROMSource(this.cddevice_no);
     this.cdromThreadStatus = true;
     
     while (this.cdromThreadStatus)
     {
       try
       {
 
         if (!VMApp.getInstance().isCDRedirRunning(this.cddevice_no)) {
           break;
         }
         this.cdromList = this.cdromRedir.getCDROMList();
         
         if (this.cdromList == null) {
           VMApp.getInstance().getIUSBRedirSession().StopCDROMRedir(this.cddevice_no, 3);
           VMApp.getVMPane().getDeviceControlPanel(0, this.cddevice_no).updateDeviceControlPanel();
         }
         else {
           for (int i = 0; i < this.cdromList.length; i++) {
             if (this.cdromSource.equals(this.cdromList[i])) {
               this.isMediaMatched = true;
               break;
             }
           }
           
 
 
           if (!this.isMediaMatched) {
             Debug.out.println("REDIRECTED CDROM MEDIUM REMOVAL HAS BEEN DETECTED, STOPPING REDIRECTION TO PREVENT FURTHER DAMAGE");
             VMApp.getInstance().getIUSBRedirSession().StopCDROMRedir(this.cddevice_no, 3);
             VMApp.getVMPane().getDeviceControlPanel(0, this.cddevice_no).updateDeviceControlPanel();
           }
           else
           {
             this.isMediaMatched = false;
           }
         }
         
         sleep(2000L);
       }
       catch (RedirectionException localRedirectionException)
       {
         stopCDRedirAbnormal();
         Debug.out.println(localRedirectionException);
       }
       catch (InterruptedException localInterruptedException)
       {
         stopCDRedirAbnormal();
         Debug.out.println(localInterruptedException);
       }
       catch (Exception localException) {
         stopCDRedirAbnormal();
         Debug.out.println(localException);
       }
     }
   }
   
 
 
   private void stopCDRedirAbnormal()
   {
     if ((!com.ami.kvm.jviewer.JViewer.isVMApp()) && 
       (JViewerApp.getInstance().getVMDialog() != null)) {
       JViewerApp.getInstance().getVMDialog().setVisible(false);
     }
     VMApp.getInstance().getIUSBRedirSession().stopCDROMAbnormal(this.cddevice_no);
   }
 }


/* Location:              D:\Users\tianlin\Downloads\JViewer.jar!\com\ami\iusb\vCDMonitorThread.class
 * Java compiler version: 5 (49.0)
 * JD-Core Version:       0.7.1
 */